# 显示欢迎信息
import random

print('*' * 20, '欢迎光临《唐僧大战白骨精》', '*' * 20)

# 游戏角色选择
print('请选择你的角色：')
print('\t1.唐僧')
print('\t2.白骨精')

# 游戏的身份选择
choosePlayer = input('请选择[1-2]：')

# 打印一条分割线
print('*' * 64)

playerName = '唐僧'
# 根据用户选择来分配身份（显示不同的提示消息）
if choosePlayer == '1':
    print('你将以->唐僧<-的身份来进行游戏!')
elif choosePlayer == '2':
    print('你将以->白骨精<-的身份来进行游戏!')
    playerName = '白骨精'
else:
    print('选择失败,自动以->唐僧<-的身份进行游戏!')

# 游戏进行
print('*' * 64)

# 初始化定义攻击力与生命值
playerAttack = 10
playerLife = 10

print(f"角色名称:{playerName}===攻击力:{playerAttack}===生命值:{playerLife}")
print('*' * 64)

# 初始化Boss的生命值与攻击力
BossAttack = 15
BossLife = 50

# 游戏选择(循环)
while True:
    print('请选择你要进行的操作：')
    print('\t1.练级')
    print('\t2.打BOSS')
    print('\t3.逃跑')
    chooseGame = input('请选择要做的操作[1-3]：')

    # 处理用户的选择
    if chooseGame == '1':
        # 练级-增加攻击力
        playerAttack += random.randint(1, 5)
        # 练级-增加生命值
        playerLife += random.randint(2, 6)
        print('*' * 64)
        print(f"{playerName}>>>当前生命值为:{playerLife},当前攻击力为:{playerAttack}>>>练级成功!")
        print(f"BOSS>>>当前生命值为:{BossLife},当前攻击力为:{BossAttack}")
        print('*' * 64)

    elif chooseGame == '2':
        # 玩家先攻击Boss,计算Boss是否死亡
        BossLife -= playerAttack
        if BossLife <= 0:
            print('*' * 64)
            print(f"{playerName}>>>当前生命值为:{playerLife},当前攻击力为:{playerAttack}>>>杀死了BOSS!")
            print(f"BOSS>>>当前生命值为:{BossLife},当前攻击力为:{BossAttack}")
            print('*' * 64)
            break
        print('*' * 64)
        print(f"{playerName}>>>当前生命值为:{playerLife},当前攻击力为:{playerAttack}>>>攻击了一次BOSS,BOSS依旧活着!")
        print(f"BOSS>>>当前生命值为:{BossLife},当前攻击力为:{BossAttack}")
        print('*' * 64)

        # 假设Boss未死,随机Boss是否反击(反击概率0.8)
        StrikeBack = random.randint(1, 10)
        if StrikeBack <= 8:
            playerLife -= BossAttack
            if playerLife <= 0:
                print('*' * 64)
                print(f"{playerName}>>>当前生命值为:{playerLife},当前攻击力为:{playerAttack}>>>被BOSS反击一次,你已死亡!")
                print(f"BOSS>>>当前生命值为:{BossLife},当前攻击力为:{BossAttack}")
                print('*' * 64)
                break

    elif chooseGame == '3':
        # 玩家逃跑了
        print('*' * 64)
        print(f"{playerName}>>>当前生命值为:{playerLife},当前攻击力为:{playerAttack}>>>你跑路了,真怂!")
        print(f"BOSS>>>当前生命值为:{BossLife},当前攻击力为:{BossAttack}")
        print('*' * 64)
        break
    else:
        print('*' * 64)
        print("不存在该选项,请重新选择!")
